<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/static/common/default.jsp"%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	</head>
	
	<body>
		<div class="breadcrumbs" id="breadcrumbs">
	
			<ul class="breadcrumb">
				<li><i class="icon-home home-icon"></i> <a href="#">首页</a></li>
				<li>商品管理</li>
				<li class="active">编辑</li>
			</ul>
			
		</div>
		
		<div class="page-content">
			<div class="page-header">
				<h1>商品管理
					<small>
					<i class="icon-double-angle-right"></i>
					编辑
					</small>					
				</h1>			
			</div> 
			<div class="row">
				<div class="col-xs-12">
					<form class="form-horizontal" onsubmit="return sysGoodsUpdate();" role="form" id="goodsForm" name="goodsForm" method="post">
						
						<div class="form-group" >
							<label class="col-sm-3 control-label no-padding-right" for="form-field-1">姓名</label>
							<div class="col-sm-9">
								<input type="text" id="goodName"  name="goodName" value="${goods.goodName}" placeholder="姓名" class="col-xs-10 col-sm-5" size="50" required/>
							</div>
						</div>
						<div class="form-group" >
							<label class="col-sm-3 control-label no-padding-right" for="form-field-1">商品编号</label>
							<div class="col-sm-9">
								<input type="text" id="goodCode"  name="goodCode" value="${goods.goodCode}" placeholder="商品编号" class="col-xs-10 col-sm-5" size="50" required/>
							</div>
						</div>
						<div class="form-group" >
							<label class="col-sm-3 control-label no-padding-right" for="form-field-1">商品价格</label>
							<div class="col-sm-9">
								<input type="text" id="goodPrice"  name="goodPrice" value="${goods.goodPrice}" placeholder="商品价格" class="col-xs-10 col-sm-5" size="50" required/>
							</div>
						</div>
						
						<div class="form-group" >
							<label class="col-sm-3 control-label no-padding-right" for="form-field-1">商品类型</label>
							<div class="col-sm-9">
							<select id="goodType">
						
								<option value="1"  <c:if test="${goods.goodType eq '1'}">selected</c:if> >错题汇总卷</option>
								<option value="2" <c:if test="${goods.goodType eq '2'}">selected</c:if> >错题扩展卷</option>
								<option value="2" <c:if test="${goods.goodType eq '3'}">selected</c:if> >错题一对一</option>
								<option value="2" <c:if test="${goods.goodType eq '4'}">selected</c:if> >学期整训</option>
								<option value="2" <c:if test="${goods.goodType eq '5'}">selected</c:if> >中考名师讲解</option>
							</select>
							</div>
						</div>
						<div class="form-group" >
							<label class="col-sm-3 control-label no-padding-right" for="form-field-1">科目</label>
							<div class="col-sm-9">
							<select id="subjectId">
							<c:choose>
								<c:when test="${goods.subjectId==1}">
								<option value="1" selected = "selected">语文</option>
								<option value="2">数学</option>
								<option value="3">英语</option>
								</c:when>
								<c:when test="${goods.subjectId==2}">
								<option value="1">语文</option>
								<option value="2" selected = "selected">数学</option>
								<option value="3">英语</option>
								</c:when>
								<c:otherwise>
								<option value="1">语文</option>
								<option value="2">数学</option>
								<option value="3" selected = "selected">英语</option>
								</c:otherwise>
							</c:choose>
							</select>
							</div>
						</div>
						<div class="form-group" >
							<label class="col-sm-3 control-label no-padding-right" for="form-field-1">价格描述</label>
							<div class="col-sm-9">
								<input type="text" id="goodPriceSummary"  name="goodPriceSummary" value="${goods.goodPriceSummary}" placeholder="价格描述" class="col-xs-10 col-sm-5" size="50" required/>
							</div>
						</div>
						<div class="form-group" >
							<label class="col-sm-3 control-label no-padding-right" for="form-field-1">商品副标题</label>
							<div class="col-sm-9">
								<input type="text" id="goodPriceTitle"  name="goodPriceTitle" value="${goods.goodPriceTitle}" placeholder="商品副标题" class="col-xs-10 col-sm-5" size="50" required/>
							</div>
						</div>
						<input type="hidden" id="goodId"  name="goodId" value="${goods.goodId}"/>
						
						<div class="clearfix form-actions">
							<div class="col-md-offset-3 col-md-9">
								<button class="btn btn-info" type="submit">
									<i class="icon-ok bigger-110"></i>提交
								</button>
							</div>
						</div>
						
					</form>		
				</div>
							
			</div>
		</div>
		
		<script type="text/javascript">
			function sysGoodsUpdate() {
				var datastr = new Object();
				datastr.goodId = $('#goodId').val();
    			datastr.goodName = $('#goodName').val();
    			datastr.goodCode = $('#goodCode').val();
    			datastr.goodPrice = $('#goodPrice').val();
    			datastr.goodType = $('#goodType').val();
    			datastr.subjectId = $('#subjectId').val();
    			datastr.goodPriceSummary = $('#goodPriceSummary').val();
    			datastr.goodPriceTitle = $('#goodPriceTitle').val();
				var result = true;
				$.ajax({
		        async: true,
		        type:"POST",
		        data:JSON.stringify(datastr),
		        url: "${ctx}/sys/goods/udpate",
		        dataType: "json",
		        headers : {  
                    'Content-Type' : 'application/json;charset=utf-8'  
                },
                    success : function(data) {
                		if (data != undefined && data.status != undefined
                				&& data.status.trim() == '0') {
                			result = true;
                			alert("修改成功！");
                			window.location.href = "${ctx}/sys/goods/goods_list";
                		} else {
                			result = false;
                			alert(data.error);
                		}
                	},
    			},"json");
				return false;
			}
			
		</script>
	</body>


</html>